package com.wrial.temp;
/*
 * @Author  Wrial
 * @Date Created in 17:21 2020/4/15
 * @Description abcdefg badcfeg
 * a a
 */

public class Main {


    static class Node{
        public Node(int val){
            this.val = val;
        }
        int val;
        Node next;
    }

    public static void main(String[] args) {

    }
    public static Node reverse(Node head){

        Node p = head;
        Node temp;
        Node ans = new Node(-1);
        Node ret = ans.next;
        while (p!=null){
            temp = p;

            if (temp.next!=null){

                ans.next = temp.next;
                ans = ans.next;
                ans.next = temp;
                p = p.next.next;
            }else {
                ans.next = temp;
                p = p.next;
            }

        }
        return ret;
    }



}
